%% Author: John
%% Created: 2010-7-21
%% Description: TODO: Add description to myerlang_log
-module(myerlang_log).

%%
%% Include files
%%

%%
%% Exported Functions
%%
-export([init/0,log/0]).

%%
%% API Functions
%%
init()->
	init_log4erl(),
%% 	io:format("io: ~p~w",log4erl:get_appenders()),
	log4erl:warn("warn2 msg"),
	log4erl:info("info2 msg"),
	log4erl:error("error2 msg").

log()->
	log4erl:warn("warn3 msg"),
	log4erl:info("info3 msg"),
	log4erl:error("error3 msg").

%%
%% Local Functions
%%
init_log4erl() ->    
    application:start(log4erl),
    log4erl:add_file_appender(test_logger,{myerlang_conf:log_directory(), "test", {size, 100000}, 10, log, info}),
    log4erl:add_file_appender(run_logger,{myerlang_conf:log_directory(), "run", {daily, 0}, 10, log, info}),
	log4erl:add_file_appender(app,{myerlang_conf:log_directory(), "app", {size, 100000}, 10, log, info}),
	log4erl:change_format(app, "%j %h:%m:%s [%L] %l%n"),
	log4erl:add_console_appender(cmd_logs, {info, "%j %T [%L] %l%n"}),
	log4erl:warn("warn1 msg"),
	log4erl:info("info1 msg"),
	log4erl:error("error1 msg").


